package com.zixi.ai.framework.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;

import java.util.List;
import java.util.Optional;

/**
 * 基础Service
 * @author linshuai
 */
public interface BaseService<T, ID> {
	List<T> findAll();
	List<T> findAll(Sort sort);
	List<T> findAll(Specification<T> spec);
	List<T> findAll(Specification<T> spec, Sort sort);
	List<T> findAll(String hql,Object...params);
	<M> List<M> findAllM(String hql,Object...params);
	<M> List<M> findAll(String sql, Class<M> cls);
	<M> Page<M> findPage(String sql, Class<M> cls,Pageable pageable);
	Page<T> findPage(Pageable pageable);
	Page<T> findPage(Specification<T> spec, Pageable pageable);
	Page<T> findPage(Specification<T> spec, Pageable pageable, Sort sort);
	void save(T t);
	void saveAll(List<T> data);
	void del(ID id);
	Optional<T> findById(ID id);
	Optional<T> findOne(Specification<T> spec);
	long count();
	long count(Specification<T> spec);
	void delAll(List<T> data);
}
